# -*- coding : utf_8 -*-
"""
=======================================
Time : 2025/4/9 21:05
Author : 田霄汉
Email : 522989570@qq.com
File : pandas_class06.py
Project : pandas_demo
Function : 多维度排序
=======================================
"""

from config.setting import file_path
import pandas as pd

excel06_path = file_path['excel_path'] + '/excel06.xlsx'

products = pd.read_excel(io=excel06_path,
                         skiprows=3,
                         usecols='C:F',
                         index_col='ID')

# 进行排序
products.sort_values(by=['WORTHY', 'PRICE'],  # 按照哪些列进行排序
                     ascending=[True, False],  # 控制排序，默认是True
                     inplace=True)  # 不创建新文档，在原文档上排序
print(products)

# 进行筛选，PRICE>10且WORTHY=='YES'
products = products.loc[products.PRICE.apply(lambda x: x > 10)]. \
    loc[products.WORTHY.apply(lambda x: x == 'YES')]
print(products)
